import { instance } from '../../request'
import { ConfigSwitchCodeEnum } from '@/type/enum'

const request = instance

/**
 * 注册账号
 * @param account  账号
 * @param password 密码
 * @returns
 * */
export const registerAccountApi = (
  account: string,
  password: string
): PromiseRes =>
  request.post(`/api/register`, {
    account,
    password,
  })

/**
 * 获取验证码
 * @returns
 */
export const verificationCodeApi = (): PromiseRes<string> =>
  request.post(`/api/verificationCode`)

/**
 * 用户登录
 * @param account 账号
 * @param password 密码
 * @param verificationCode 验证码
 * @returns
 */
export const loginApi = (
  account: string,
  password: string,
  verificationCode: string
): PromiseRes =>
  request.post(`/api/login?code=${verificationCode}`, {
    account,
    password,
  })

/**
 * 判断某个系统配置开关，配置功能是否启用了
 * @param configCode 配置编码
 * @returns
 */
export const judgeConfigSwitchStatusApi = (
  configCode: ConfigSwitchCodeEnum
): PromiseRes<boolean> =>
  request.post(`/api/judgeConfigSwitchStatus?configCode=${configCode}`)
